home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Tool Chest / Development Platforms / Macintosh Common Lisp Related / interfaces / PInterface Translator / PInterfaces / TextEdit.p < prev    next >
Encoding:
Text File  |  1993-09-16  |  10.6 KB  |  320 lines  |  [TEXT/MPS ]

  1. {
  2. Created: Sunday, January 6, 1991 at 11:23 PM
  3.     TextEdit.p
  4.     Pascal Interface to the Macintosh Libraries
  5.  
  6.         Copyright Apple Computer, Inc.    1985-1990
  7.         All rights reserved
  8. }
  9.  
  10.  
  11. {$IFC UNDEFINED UsingIncludes}
  12. {$SETC UsingIncludes := 0}
  13. {$ENDC}
  14.  
  15. {$IFC NOT UsingIncludes}
  16.     UNIT TextEdit;
  17.     INTERFACE
  18. {$ENDC}
  19.  
  20. {$IFC UNDEFINED UsingTextEdit}
  21. {$SETC UsingTextEdit := 1}
  22.  
  23. {$I+}
  24. {$SETC TextEditIncludes := UsingIncludes}
  25. {$SETC UsingIncludes := 1}
  26. {$IFC UNDEFINED UsingQuickdraw}
  27. {$I $$Shell(PInterfaces)Quickdraw.p}
  28. {$ENDC}
  29. {$SETC UsingIncludes := TextEditIncludes}
  30.  
  31. CONST
  32.  
  33. { Justification styles }
  34. teJustLeft = 0;
  35. teJustCenter = 1;
  36. teJustRight = -1;
  37. teForceLeft = -2;
  38.  
  39. { new names for the Justification styles }
  40. teFlushDefault = 0;                     {flush according to the line direction }
  41. teCenter = 1;                           {center justify }
  42. teFlushRight = -1;                      {flush right for all scripts }
  43. teFlushLeft = -2;                       {flush left for all scripts }
  44.  
  45. { Set/Replace style modes }
  46. fontBit = 0;                            {set font}
  47. faceBit = 1;                            {set face}
  48. sizeBit = 2;                            {set size}
  49. clrBit = 3;                             {set color}
  50. addSizeBit = 4;                         {add size mode}
  51. toglBit = 5;                            {set faces in toggle mode}
  52.  
  53. { TESetStyle/TEContinuousStyle modes }
  54. doFont = 1;                             { set font (family) number}
  55. doFace = 2;                             {set character style}
  56. doSize = 4;                             {set type size}
  57. doColor = 8;                            {set color}
  58. doAll = 15;                             {set all attributes}
  59. addSize = 16;                           {adjust type size}
  60. doToggle = 32;                          {toggle mode for TESetStyle & TEContinuousStyle}
  61.  
  62. { offsets into TEDispatchRec }
  63. EOLHook = 0;                            {[ProcPtr] TEEOLHook}
  64. DRAWHook = 4;                           {[ProcPtr] TEWidthHook}
  65. WIDTHHook = 8;                          {[ProcPtr] TEDrawHook}
  66. HITTESTHook = 12;                       {[ProcPtr] TEHitTestHook}
  67. nWIDTHHook = 24;                        {[ProcPtr] nTEWidthHook}
  68. TextWidthHook = 28;                     {[ProcPtr] TETextWidthHook}
  69.  
  70. { selectors for TECustomHook }
  71. intEOLHook = 0;                         {TEIntHook value}
  72. intDrawHook = 1;                        {TEIntHook value}
  73. intWidthHook = 2;                       {TEIntHook value}
  74. intHitTestHook = 3;                     {TEIntHook value}
  75. intNWidthHook = 6;                      {TEIntHook value for new version of WidthHook}
  76. intTextWidthHook = 7;                   {TEIntHook value for new TextWidthHook}
  77.  
  78. { feature or bit definitions for TEFeatureFlag }
  79. teFAutoScr = 0;                         {00000001b}
  80. teFTextBuffering = 1;                   {00000010b}
  81. teFOutlineHilite = 2;                   {00000100b}
  82. teFInlineInput = 3;                     {00001000b}
  83. teFUseTextServices = 4;                 {00010000b}
  84.  
  85. { action for the new "bit (un)set" interface, TEFeatureFlag }
  86. TEBitClear = 0;
  87. TEBitSet = 1;                           {set the selector bit}
  88. TEBitTest = -1;                         {no change; just return the current setting}
  89.  
  90. {constants for identifying the routine that called FindWord }
  91. teWordSelect = 4;                       {clickExpand to select word}
  92. teWordDrag = 8;                         {clickExpand to drag new word}
  93. teFromFind = 12;                        {FindLine called it ($0C)}
  94. teFromRecal = 16;                       {RecalLines called it ($10)}
  95.  
  96. TYPE
  97. TEPtr = ^TERec;
  98. TEHandle = ^TEPtr;
  99. TERec = RECORD
  100.     destRect: Rect;
  101.     viewRect: Rect;
  102.     selRect: Rect;
  103.     lineHeight: INTEGER;
  104.     fontAscent: INTEGER;
  105.     selPoint: Point;
  106.     selStart: INTEGER;
  107.     selEnd: INTEGER;
  108.     active: INTEGER;
  109.     wordBreak: ProcPtr;
  110.     clikLoop: ProcPtr;
  111.     clickTime: LONGINT;
  112.     clickLoc: INTEGER;
  113.     caretTime: LONGINT;
  114.     caretState: INTEGER;
  115.     just: INTEGER;
  116.     teLength: INTEGER;
  117.     hText: Handle;
  118.     recalBack: INTEGER;
  119.     recalLines: INTEGER;
  120.     clikStuff: INTEGER;
  121.     crOnly: INTEGER;
  122.     txFont: INTEGER;
  123.     txFace: Style;                      {txFace is unpacked byte}
  124.     txMode: INTEGER;
  125.     txSize: INTEGER;
  126.     inPort: GrafPtr;
  127.     highHook: ProcPtr;
  128.     caretHook: ProcPtr;
  129.     nLines: INTEGER;
  130.     lineStarts: ARRAY [0..16000] OF INTEGER;
  131.     END;
  132.  
  133. CharsPtr = ^Chars;
  134. CharsHandle = ^CharsPtr;
  135.  
  136. Chars = PACKED ARRAY [0..32000] OF CHAR;
  137.  
  138. StyleRun = RECORD
  139.     startChar: INTEGER;                 {starting character position}
  140.     styleIndex: INTEGER;                {index in style table}
  141.     END;
  142.  
  143. STElement = RECORD
  144.     stCount: INTEGER;                   {number of runs in this style}
  145.     stHeight: INTEGER;                  {line height}
  146.     stAscent: INTEGER;                  {font ascent}
  147.     stFont: INTEGER;                    {font (family) number}
  148.     stFace: Style;                      {character Style}
  149.     stSize: INTEGER;                    {size in points}
  150.     stColor: RGBColor;                  {absolute (RGB) color}
  151.     END;
  152.  
  153. STPtr = ^TEStyleTable;
  154. STHandle = ^STPtr;
  155.  
  156. TEStyleTable = ARRAY [0..1776] OF STElement;
  157.  
  158. LHElement = RECORD
  159.     lhHeight: INTEGER;                  {maximum height in line}
  160.     lhAscent: INTEGER;                  {maximum ascent in line}
  161.     END;
  162.  
  163. LHPtr = ^LHTable;
  164. LHHandle = ^LHPtr;
  165.  
  166. LHTable = ARRAY [0..8000] OF LHElement;
  167.  
  168. ScrpSTElement = RECORD
  169.     scrpStartChar: LONGINT;             {starting character position}
  170.     scrpHeight: INTEGER;                {starting character position}
  171.     scrpAscent: INTEGER;
  172.     scrpFont: INTEGER;
  173.     scrpFace: Style;                    {unpacked byte}
  174.     scrpSize: INTEGER;
  175.     scrpColor: RGBColor;
  176.     END;
  177.  
  178. ScrpSTTable = ARRAY[0..1600] OF ScrpSTElement;
  179.  
  180. StScrpPtr = ^StScrpRec;
  181. StScrpHandle = ^StScrpPtr;
  182. StScrpRec = RECORD
  183.     scrpNStyles: INTEGER;               {number of styles in scrap}
  184.     scrpStyleTab: ScrpSTTable;          {table of styles for scrap}
  185.     END;
  186.  
  187. NullStPtr = ^NullStRec;
  188. NullStHandle = ^NullStPtr;
  189. NullStRec = RECORD
  190.     teReserved: LONGINT;                {reserved for future expansion}
  191.     nullScrap: StScrpHandle;            {handle to scrap style table}
  192.     END;
  193.  
  194. TEStylePtr = ^TEStyleRec;
  195. TEStyleHandle = ^TEStylePtr;
  196. TEStyleRec = RECORD
  197.     nRuns: INTEGER;                     {number of style runs}
  198.     nStyles: INTEGER;                   {size of style table}
  199.     styleTab: STHandle;                 {handle to style table}
  200.     lhTab: LHHandle;                    {handle to line-height table}
  201.     teRefCon: LONGINT;                  {reserved for application use}
  202.     nullStyle: NullStHandle;            {Handle to style set at null selection}
  203.     runs: ARRAY [0..8000] OF StyleRun;  {ARRAY [0..8000] OF StyleRun}
  204.     END;
  205.  
  206. TextStylePtr = ^TextStyle;
  207. TextStyleHandle = ^TextStylePtr;
  208. TextStyle = RECORD
  209.     tsFont: INTEGER;                    {font (family) number}
  210.     tsFace: Style;                      {character Style}
  211.     tsSize: INTEGER;                    {size in point}
  212.     tsColor: RGBColor;                  {absolute (RGB) color}
  213.     END;
  214.  
  215.  
  216. TEIntHook = INTEGER;
  217.  
  218. PROCEDURE TEInit;
  219.     INLINE $A9CC;
  220. FUNCTION TENew(destRect: Rect;viewRect: Rect): TEHandle;
  221.     INLINE $A9D2;
  222. PROCEDURE TEDispose(hTE: TEHandle);
  223.     INLINE $A9CD;
  224. PROCEDURE TESetText(text: Ptr;length: LONGINT;hTE: TEHandle);
  225.     INLINE $A9CF;
  226. FUNCTION TEGetText(hTE: TEHandle): CharsHandle;
  227.     INLINE $A9CB;
  228. PROCEDURE TEIdle(hTE: TEHandle);
  229.     INLINE $A9DA;
  230. PROCEDURE TESetSelect(selStart: LONGINT;selEnd: LONGINT;hTE: TEHandle);
  231.     INLINE $A9D1;
  232. PROCEDURE TEActivate(hTE: TEHandle);
  233.     INLINE $A9D8;
  234. PROCEDURE TEDeactivate(hTE: TEHandle);
  235.     INLINE $A9D9;
  236. PROCEDURE TEKey(key: CHAR;hTE: TEHandle);
  237.     INLINE $A9DC;
  238. PROCEDURE TECut(hTE: TEHandle);
  239.     INLINE $A9D6;
  240. PROCEDURE TECopy(hTE: TEHandle);
  241.     INLINE $A9D5;
  242. PROCEDURE TEPaste(hTE: TEHandle);
  243.     INLINE $A9DB;
  244. PROCEDURE TEDelete(hTE: TEHandle);
  245.     INLINE $A9D7;
  246. PROCEDURE TEInsert(text: Ptr;length: LONGINT;hTE: TEHandle);
  247.     INLINE $A9DE;
  248. PROCEDURE TESetJust(just: INTEGER;hTE: TEHandle);
  249.     INLINE $A9DF;
  250. PROCEDURE TEUpdate(rUpdate: Rect;hTE: TEHandle);
  251.     INLINE $A9D3;
  252. PROCEDURE TextBox(text: Ptr;length: LONGINT;box: Rect;just: INTEGER);
  253.     INLINE $A9CE;
  254. PROCEDURE TEScroll(dh: INTEGER;dv: INTEGER;hTE: TEHandle);
  255.     INLINE $A9DD;
  256. PROCEDURE TESelView(hTE: TEHandle);
  257.     INLINE $A811;
  258. PROCEDURE TEPinScroll(dh: INTEGER;dv: INTEGER;hTE: TEHandle);
  259.     INLINE $A812;
  260. PROCEDURE TEAutoView(fAuto: BOOLEAN;hTE: TEHandle);
  261.     INLINE $A813;
  262. FUNCTION TEScrapHandle: Handle;
  263.     INLINE $2EB8,$0AB4;
  264. PROCEDURE TECalText(hTE: TEHandle);
  265.     INLINE $A9D0;
  266. FUNCTION TEGetOffset(pt: Point;hTE: TEHandle): INTEGER;
  267.     INLINE $A83C;
  268. FUNCTION TEGetPoint(offset: INTEGER;hTE: TEHandle): Point;
  269.     INLINE $3F3C,$0008,$A83D;
  270. PROCEDURE TEClick(pt: Point;fExtend: BOOLEAN;h: TEHandle);
  271.     INLINE $A9D4;
  272. FUNCTION TEStylNew(destRect: Rect;viewRect: Rect): TEHandle;
  273.     INLINE $A83E;
  274. PROCEDURE SetStylHandle(theHandle: TEStyleHandle;hTE: TEHandle);
  275.     INLINE $3F3C,$0005,$A83D;
  276. FUNCTION GetStylHandle(hTE: TEHandle): TEStyleHandle;
  277.     INLINE $3F3C,$0004,$A83D;
  278. PROCEDURE TEGetStyle(offset: INTEGER;VAR theStyle: TextStyle;VAR lineHeight: INTEGER;
  279.     VAR fontAscent: INTEGER;hTE: TEHandle);
  280.     INLINE $3F3C,$0003,$A83D;
  281. PROCEDURE TEStylPaste(hTE: TEHandle);
  282.     INLINE $3F3C,$0000,$A83D;
  283. PROCEDURE TESetStyle(mode: INTEGER;newStyle: TextStyle;redraw: BOOLEAN;
  284.     hTE: TEHandle);
  285.     INLINE $3F3C,$0001,$A83D;
  286. PROCEDURE TEReplaceStyle(mode: INTEGER;oldStyle: TextStyle;newStyle: TextStyle;
  287.     redraw: BOOLEAN;hTE: TEHandle);
  288.     INLINE $3F3C,$0002,$A83D;
  289. FUNCTION GetStylScrap(hTE: TEHandle): StScrpHandle;
  290.     INLINE $3F3C,$0006,$A83D;
  291. PROCEDURE TEStylInsert(text: Ptr;length: LONGINT;hST: StScrpHandle;hTE: TEHandle);
  292.     INLINE $3F3C,$0007,$A83D;
  293. FUNCTION TEGetHeight(endLine: LONGINT;startLine: LONGINT;hTE: TEHandle): LONGINT;
  294.     INLINE $3F3C,$0009,$A83D;
  295. FUNCTION TEContinuousStyle(VAR mode: INTEGER;VAR aStyle: TextStyle;hTE: TEHandle): BOOLEAN;
  296.     INLINE $3F3C,$000A,$A83D;
  297. PROCEDURE SetStylScrap(rangeStart: LONGINT;rangeEnd: LONGINT;newStyles: StScrpHandle;
  298.     redraw: BOOLEAN;hTE: TEHandle);
  299.     INLINE $3F3C,$000B,$A83D;
  300. PROCEDURE TECustomHook(which: TEIntHook;VAR addr: ProcPtr;hTE: TEHandle);
  301.     INLINE $3F3C,$000C,$A83D;
  302. FUNCTION TENumStyles(rangeStart: LONGINT;rangeEnd: LONGINT;hTE: TEHandle): LONGINT;
  303.     INLINE $3F3C,$000D,$A83D;
  304. FUNCTION TEFeatureFlag(feature: INTEGER;action: INTEGER;hTE: TEHandle): INTEGER;
  305.     INLINE $3F3C,$000E,$A83D;
  306. FUNCTION TEGetScrapLen: LONGINT;
  307. PROCEDURE TESetScrapLen(length: LONGINT);
  308. FUNCTION TEFromScrap: OSErr;
  309. FUNCTION TEToScrap: OSErr;
  310. PROCEDURE SetClikLoop(clikProc: ProcPtr;hTE: TEHandle);
  311. PROCEDURE SetWordBreak(wBrkProc: ProcPtr;hTE: TEHandle);
  312.  
  313.  
  314. {$ENDC}    { UsingTextEdit }
  315.  
  316. {$IFC NOT UsingIncludes}
  317.     END.
  318. {$ENDC}
  319.  
  320.